package cn.alm.springaiollama.controller;

import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("ollama")
public class OllamaController {

    @Autowired
    private OllamaChatModel chatModel;

    @GetMapping(value = "stream", produces = "text/html;charset=UTF-8")
    public Flux<String> stream(@RequestParam String question) {
        Flux<String> stream = chatModel.stream(question);
        return stream;
    }

}
